package com.wedo.mall.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.e.library.adapter.Adapter;
import com.e.library.adapter.EAdapter;
import com.wedo.mall.R;
import com.wedo.mall.entity.Favourable;

import java.util.List;

/**
 * Created by lxy on 2017/6/19.
 */

public class FavourableAdapter extends Adapter<Favourable> {
    public FavourableAdapter(Context context, List<Favourable> datas) {
        super(context, datas);
    }

    @Override
    protected int layout() {
        return R.layout.item_favourable;
    }

    @Override
    protected void bind(EHolder holder, Favourable favourable, int position) {
        ImageView iv_img = holder.find(R.id.iv_img);
        TextView tv_name= holder.find(R.id.tv_name);
        TextView tv_price = holder.find(R.id.tv_price);
        TextView tv_original_price = holder.find(R.id.tv_original_price);
        TextView tv_cost = holder.find(R.id.tv_cost);

        tv_name.setText(favourable.name);
        tv_price.setText(String.format("￥%s元",favourable.price));
        Glide.with(mContext).load(favourable.img).diskCacheStrategy(DiskCacheStrategy.ALL).into(iv_img);
    }
}
